package spring.learn.tx.service;

import org.mybatis.spring.mapper.MapperFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import spring.learn.tx.mapper.UserMapper;

/**
 * Description
 * Copyright © 启明星辰 版权所有
 *
 * @author chenjiquan
 * @date 2024-09-11
 */
@Service
public class UserService {

	UserMapper userMapper;
	UserService userService;

	AService aService;

	public UserService(UserMapper userMapper, @Lazy UserService userService, @Autowired(required = false) @Lazy AService aService) {
		this.userMapper = userMapper;
		this.userService = userService;
		this.aService = aService;
	}

	@Transactional
	public int insert() {
		int i = userMapper.insert();
//		userService.update();
		return 1;
	}

	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public int update() {
		int i= userMapper.update();
//		throw new RuntimeException("异常");
		return i;
	}

}
